package top.yokey.shopnc.model;

import top.yokey.base.base.BaseHttpClient;
import top.yokey.base.base.BaseHttpListener;

@SuppressWarnings("ALL")
public class MemberChatModel {

    private final String ACT = "member_chat";
    private static volatile MemberChatModel instance;

    public static MemberChatModel get() {
        if (instance == null) {
            synchronized (MemberChatModel.class) {
                if (instance == null) {
                    instance = new MemberChatModel();
                }
            }
        }
        return instance;
    }

    public void getUserList(BaseHttpListener baseHttpListener) {

        BaseHttpClient.get().ready(ACT, "get_user_list")
                .add("recent", "1")
                .post(baseHttpListener);

    }

    public void getMsgCount(BaseHttpListener baseHttpListener) {

        BaseHttpClient.get().ready(ACT, "get_msg_count").get(baseHttpListener);

    }

    public void getChatLog(String memberId, BaseHttpListener baseHttpListener) {

        BaseHttpClient.get().ready(ACT, "get_chat_log", "page", "999")
                .add("t_id", memberId)
                .add("t", "30")
                .post(baseHttpListener);

    }

    public void getNodeInfo(String memberId, String goodsId, BaseHttpListener baseHttpListener) {

        BaseHttpClient.get().ready(ACT, "get_node_info")
                .add("u_id", memberId)
                .add("chat_goods_id", goodsId)
                .get(baseHttpListener);

    }

    public void sendMessage(String memberId, String memberName, String message, String goodsId, BaseHttpListener baseHttpListener) {

        BaseHttpClient.get().ready(ACT, "send_msg")
                .add("t_id", memberId)
                .add("t_name", memberName)
                .add("t_msg", message)
                .add("chat_goods_id", goodsId)
                .post(baseHttpListener);

    }

}
